<template>
  <div>
    <ul class="videoList">
      <li
        v-for="(i, index) in itemList"
        :key="index"
        
      >
        <div class="video">
          <video
            controls="true"
            preload="auto"
            loop="loop"
            :src="i.data.playUrl"
          ></video>
        </div>
        <div class="info" @click="toVideo(i.data.id)">
          <div class="author">
            <img :src="i.data.author.icon" alt="" />
          </div>
          <div class="introduce">
            <p class="title">{{ i.data.title }}</p>
            <span>{{ i.data.author.name }}</span>
          </div>
        </div>
      </li>
    </ul>
    <ul class="vu">
      <li class="videoWithCover" v-for="i in videoWithCover" :key="i.data.id">
        <div class="cover"><img :src="i.data.cover.feed" alt="" /></div>
        <div class="info2">
          <p class="title">{{ i.data.title }}</p>
          <span class="category">#{{ i.data.category }}</span>
         
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      itemList: [],
      videoWithCover: [],
      date:'1623718800000',
      page:2
    };
  },
  methods: {
    toVideo(id) {
      this.$router.push({path:'/video',query:{id:id,date:this.date,page:this.page}})
    },
  },
  mounted() {
    this.$request({
      url: "/api/v4/tabs/selected",
      params: {
        date: this.date,
        page: this.page,
      },
    }).then((success) => {
      success.data.itemList.forEach((i) => {
        if (i.type == "video") {
          this.itemList.push(i);
        } else if (i.type == "videoCollectionWithCover") {
          this.videoWithCover = i.data.itemList;
        }
      });
      console.log(this.videoWithCover);
    });
  }
};
</script>

<style scoped>
.videoList li {
  height: 9.2rem;
  margin-bottom: 2rem;
}
.video video {
  width: 100%;
  height: 8.47rem;
  background-color: rgba(0, 0, 0, 1);
}
.info {
  display: flex;
  height: 2rem;
  margin: 0.3rem;
  border-bottom: 1px solid #ccc;
}
.author {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 0.75rem;
  overflow: hidden;
  margin-right: 0.4rem;
}
.author img {
  width: 1.5rem;
}
.title {
  font-size: 0.5rem;
  font-weight: bold;
}
.introduce span {
  font-size: 0.32rem;
  color: #ccc;
}
video::-webkit-media-controls-play-button {
  background-color: transparent;
}
.videoWithCover {
  display: flex;
  padding: 0 0.4rem;
  margin-bottom: 0.4rem;
}
.cover img {
  width: 6rem;
  vertical-align: middle;
}
.info2 {
  position: relative;
  width: 100%;
  padding-left: 0.4rem;
  padding-top: 0.4rem;
  border: 1px solid #ccc;
}
.vu li:last-child {
  margin-bottom: 2rem;
}
.category {
  font-size: 0.32rem;
  color: #ccc;
  position: absolute;
  bottom: 0.4rem;
}

</style>